<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Форум PHP-MyAdmin.RU &mdash; Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
		<link>https://forum.php-myadmin.ru/viewtopic.php?id=2980</link>
		<atom:link href="https://forum.php-myadmin.ru/extern.php?action=feed&amp;tid=2980&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Скрипт одновременной загрузки стилей/скриптов в <head>».]]></description>
		<lastBuildDate>Sun, 30 Jun 2013 08:32:07 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=23342#p23342</link>
			<description><![CDATA[<p>Скорость загрузки со скриптом выше примерно в 2 раза, на моем сайте это на 2 секунды...</p>]]></description>
			<author><![CDATA[null@example.com (Hase)]]></author>
			<pubDate>Sun, 30 Jun 2013 08:32:07 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=23342#p23342</guid>
		</item>
		<item>
			<title><![CDATA[Re: Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=23331#p23331</link>
			<description><![CDATA[<p>То что кеширует - это хорошо. Просто следует заранее предусмотреть механизм сброса кеша, например при обновлении версии jQuery.</p><p>Посмотрите скорость загрузки страниц через профилирование для страниц с динамической подгрузкой и статической. Не всегда есть смысл делать подгрузку динамически.</p>]]></description>
			<author><![CDATA[null@example.com (Hanut)]]></author>
			<pubDate>Fri, 28 Jun 2013 09:15:52 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=23331#p23331</guid>
		</item>
		<item>
			<title><![CDATA[Re: Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=23329#p23329</link>
			<description><![CDATA[<p>А то что кеширует это плохо? Ну тогда можно например после загрузки скрипта выводить время в микросекундах, например: jquery.js?*тут время*<br />Это отменит кеш...</p>]]></description>
			<author><![CDATA[null@example.com (Hase)]]></author>
			<pubDate>Thu, 27 Jun 2013 18:04:46 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=23329#p23329</guid>
		</item>
		<item>
			<title><![CDATA[Re: Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=23327#p23327</link>
			<description><![CDATA[<div class="quotebox"><cite>Hanut сказал:</cite><blockquote><p>Этот скрипт постоянно подгружает внешние скрипты и стили, или кеширует их? Проверьте этот момент.</p></blockquote></div><p>Кеширует...</p>]]></description>
			<author><![CDATA[null@example.com (Hase)]]></author>
			<pubDate>Thu, 27 Jun 2013 17:41:16 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=23327#p23327</guid>
		</item>
		<item>
			<title><![CDATA[Re: Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=23324#p23324</link>
			<description><![CDATA[<p>Этот скрипт постоянно подгружает внешние скрипты и стили, или кеширует их? Проверьте этот момент.</p>]]></description>
			<author><![CDATA[null@example.com (Hanut)]]></author>
			<pubDate>Thu, 27 Jun 2013 17:33:27 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=23324#p23324</guid>
		</item>
		<item>
			<title><![CDATA[Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=23322#p23322</link>
			<description><![CDATA[<p>Собственно я написал скрипт, но не может быть такого, чтобы он был идеальным, ибо до меня его уже написали бы (сейчас все подобные скрипты занимают не один файл размеров в не одну сотню строк). Получается, в моем есть огрехи - безопасность, неэффективность, работа через раз и т.п.<br />Но пока я его тестил сам, ни одного бага не выявил: страница загружается быстрее и в консоли отображается верная отладочная инфа. Мб вы меня натолкнете на мысль что в нем может быть не так?)</p><div class="codebox"><pre><code>            var loadJavaScriptFiles = {
                jQuery : &quot;ljs&quot;,
                core : &quot;js&quot;,
                common : &quot;tjs&quot;,
            }
            
            function setCallbacks(fileref, fname) {
                fileref.onload = function() {
                    console.log(fname + &quot; loaded successfully&quot;);
                    if (fname == &quot;common.js&quot;) {
                        try {
                            common();
                        } catch(e) {
                            console.log(e + &quot; - wait for loading jQuery.js&quot;);
                        }
                    }
                    if (fname == &quot;jQuery.js&quot;) {
                        try {
                            common();
                        } catch(e) {
                            console.log(e + &quot; - wait for loading common.js&quot;);
                        }
                    }
                };
                fileref.onerror = function() {
                    console.log(&quot;Some error occurred with loading &quot; + fname);
                };
            }

            function dynamicLoad(filesArray){
                var i = 0
                var fname = new Array;
                var fileref = new Array;
                var fileSRC = {
                    ljs : &quot;engine/javascript/library/&quot;,
                    js : &quot;engine/javascript/&quot;,
                    tjs : &quot;templates/ru/defalut/javascript/&quot;,
                    css : &quot;engine/pages/css/&quot;,
                    tcss : &quot;templates/ru/defalut/css&quot;
                };
                for (var key in filesArray) {
                    var filetype = filesArray[key];
                    var fileName = key;
                    if (filetype==&quot;js&quot;|| filetype==&quot;ljs&quot; || filetype==&quot;tjs&quot;) {
                        fileref[i]=document.createElement(&#039;script&#039;);
                        fileref[i].setAttribute(&quot;type&quot;,&quot;text/javascript&quot;);
                        fileref[i].setAttribute(&quot;src&quot;, fileSRC[filetype] + fileName + &quot;.js&quot;);
                        fname[i] = fileName + &quot;.js&quot;;
                    } else 
                    if (filetype==&quot;css&quot; || filetype==&quot;tcss&quot;){
                        fileref[i]=document.createElement(&quot;link&quot;);
                        fileref[i].setAttribute(&quot;rel&quot;, &quot;stylesheet&quot;);
                        fileref[i].setAttribute(&quot;type&quot;, &quot;text/css&quot;);
                        fileref[i].setAttribute(&quot;href&quot;, fileSRC[filetype] + fileName + &quot;.css&quot;);
                        fname[i] = fileName + &quot;.css&quot;;
                    };
                    if (typeof fileref[i]!=&quot;undefined&quot;) {
                        document.getElementsByTagName(&quot;head&quot;)[0].appendChild(fileref[i]);
                    };
                    i = i + 1;
                };
                for (i = 0; i&lt;fileref.length; i++) {
                    setCallbacks(fileref[i], fname[i]);
                };
            };

dynamicLoad(loadJavaScriptFiles);</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Hase)]]></author>
			<pubDate>Thu, 27 Jun 2013 15:48:59 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=23322#p23322</guid>
		</item>
	</channel>
</rss>
