<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aleksandr Zidyganov</title>
    <description>The latest articles on DEV Community by Aleksandr Zidyganov (@csscoder).</description>
    <link>https://dev.to/csscoder</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1123111%2Fb944a81b-2632-4651-9abe-175729d10345.png</url>
      <title>DEV Community: Aleksandr Zidyganov</title>
      <link>https://dev.to/csscoder</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/csscoder"/>
    <language>en</language>
    <item>
      <title>Website preloader as Web Component</title>
      <dc:creator>Aleksandr Zidyganov</dc:creator>
      <pubDate>Mon, 24 Jul 2023 06:52:51 +0000</pubDate>
      <link>https://dev.to/csscoder/website-preloader-as-web-component-2n54</link>
      <guid>https://dev.to/csscoder/website-preloader-as-web-component-2n54</guid>
      <description>&lt;p&gt;Greetings! Today, I aspire to expound upon my open-source endeavor &lt;a href="https://github.com/csscoder/true-preloader-core/tree/main"&gt;true-preloader-core&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The primary objectives that this solution addresses are as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Harnessing the versatility of any animation of your choice.&lt;/li&gt;
&lt;li&gt;Demonstrating the animation prior to the page loading.&lt;/li&gt;
&lt;li&gt;Customizing browser display options:

&lt;ul&gt;
&lt;li&gt;Upon each website visitation.&lt;/li&gt;
&lt;li&gt;Upon refreshing the page.&lt;/li&gt;
&lt;li&gt;Upon transitioning to a new page (except in the case of single-page applications).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Programmatically managing the concealment of the preloader:

&lt;ul&gt;
&lt;li&gt;Establishing a minimum display duration.&lt;/li&gt;
&lt;li&gt;Specifying a maximum display duration.&lt;/li&gt;
&lt;li&gt;Triggering an event upon concealing the preloader.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Ensuring the preloader possesses a minimal size.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To initialize the preloader on your website, it will be necessary to include two JavaScript files within the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section. The first file encompasses the preloader animation, while the second file comprises the core functionality of the preloader.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
 ...
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;'preloader-animation.js'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;'preloader-core.js'&lt;/span&gt;  
    &lt;span class="na"&gt;data-preloader&lt;/span&gt; 
    &lt;span class="na"&gt;data-build-version=&lt;/span&gt;&lt;span class="s"&gt;'v111112'&lt;/span&gt;
    &lt;span class="na"&gt;data-frequency=&lt;/span&gt;&lt;span class="s"&gt;'always'&lt;/span&gt;
    &lt;span class="na"&gt;data-duration-hide=&lt;/span&gt;&lt;span class="s"&gt;'300'&lt;/span&gt; 
    &lt;span class="na"&gt;data-time-fallback=&lt;/span&gt;&lt;span class="s"&gt;'5000'&lt;/span&gt;
    &lt;span class="na"&gt;data-min-show-time=&lt;/span&gt;&lt;span class="s"&gt;'2000'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  ...
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Crafting the Animation File
&lt;/h2&gt;

&lt;p&gt;To create the preloader-animation.js file, we utilize the template-preloader.js as a foundation. You can find it here: &lt;a href="https://raw.githubusercontent.com/csscoder/true-preloader-core/main/demo/preloader/template-preloader.js"&gt;template-preloader.js&lt;/a&gt;. Next, we incorporate the desired animation, such as the CSS animation from Codepen: &lt;a href="https://codepen.io/mrrocks/pen/ExLovj"&gt;example&lt;/a&gt;. Adapting it to suit the preloader's requirements, the resulting content of the file will be as follows: &lt;a href="https://github.com/csscoder/true-preloader-core/blob/main/demo/preloader/example2.js"&gt;preloader-animation.js&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Then, proceed to include these two files within your website, acquiring a fully functional preloader. See the live demonstration here: &lt;a href="https://csscoder.github.io/true-preloader-core/demo/webpage/index.html"&gt;DEMO&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For an overview of the available options, please refer to the &lt;a href="https://github.com/csscoder/true-preloader-core"&gt;project page&lt;/a&gt; &lt;a href="https://github.com/csscoder/true-preloader-core"&gt;https://github.com/csscoder/true-preloader-core&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
