<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Форум PHP-MyAdmin.RU &mdash; Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
	<link rel="self" href="https://forum.php-myadmin.ru/extern.php?action=feed&amp;tid=2980&amp;type=atom" />
	<updated>2013-06-30T08:32:07Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.php-myadmin.ru/viewtopic.php?id=2980</id>
		<entry>
			<title type="html"><![CDATA[Re: Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
			<link rel="alternate" href="https://forum.php-myadmin.ru/viewtopic.php?pid=23342#p23342" />
			<content type="html"><![CDATA[<p>Скорость загрузки со скриптом выше примерно в 2 раза, на моем сайте это на 2 секунды...</p>]]></content>
			<author>
				<name><![CDATA[Hase]]></name>
				<uri>https://forum.php-myadmin.ru/profile.php?id=4004</uri>
			</author>
			<updated>2013-06-30T08:32:07Z</updated>
			<id>https://forum.php-myadmin.ru/viewtopic.php?pid=23342#p23342</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
			<link rel="alternate" href="https://forum.php-myadmin.ru/viewtopic.php?pid=23331#p23331" />
			<content type="html"><![CDATA[<p>То что кеширует - это хорошо. Просто следует заранее предусмотреть механизм сброса кеша, например при обновлении версии jQuery.</p><p>Посмотрите скорость загрузки страниц через профилирование для страниц с динамической подгрузкой и статической. Не всегда есть смысл делать подгрузку динамически.</p>]]></content>
			<author>
				<name><![CDATA[Hanut]]></name>
				<uri>https://forum.php-myadmin.ru/profile.php?id=181</uri>
			</author>
			<updated>2013-06-28T09:15:52Z</updated>
			<id>https://forum.php-myadmin.ru/viewtopic.php?pid=23331#p23331</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
			<link rel="alternate" href="https://forum.php-myadmin.ru/viewtopic.php?pid=23329#p23329" />
			<content type="html"><![CDATA[<p>А то что кеширует это плохо? Ну тогда можно например после загрузки скрипта выводить время в микросекундах, например: jquery.js?*тут время*<br />Это отменит кеш...</p>]]></content>
			<author>
				<name><![CDATA[Hase]]></name>
				<uri>https://forum.php-myadmin.ru/profile.php?id=4004</uri>
			</author>
			<updated>2013-06-27T18:04:46Z</updated>
			<id>https://forum.php-myadmin.ru/viewtopic.php?pid=23329#p23329</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
			<link rel="alternate" href="https://forum.php-myadmin.ru/viewtopic.php?pid=23327#p23327" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Hanut сказал:</cite><blockquote><p>Этот скрипт постоянно подгружает внешние скрипты и стили, или кеширует их? Проверьте этот момент.</p></blockquote></div><p>Кеширует...</p>]]></content>
			<author>
				<name><![CDATA[Hase]]></name>
				<uri>https://forum.php-myadmin.ru/profile.php?id=4004</uri>
			</author>
			<updated>2013-06-27T17:41:16Z</updated>
			<id>https://forum.php-myadmin.ru/viewtopic.php?pid=23327#p23327</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
			<link rel="alternate" href="https://forum.php-myadmin.ru/viewtopic.php?pid=23324#p23324" />
			<content type="html"><![CDATA[<p>Этот скрипт постоянно подгружает внешние скрипты и стили, или кеширует их? Проверьте этот момент.</p>]]></content>
			<author>
				<name><![CDATA[Hanut]]></name>
				<uri>https://forum.php-myadmin.ru/profile.php?id=181</uri>
			</author>
			<updated>2013-06-27T17:33:27Z</updated>
			<id>https://forum.php-myadmin.ru/viewtopic.php?pid=23324#p23324</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Скрипт одновременной загрузки стилей/скриптов в <head>]]></title>
			<link rel="alternate" href="https://forum.php-myadmin.ru/viewtopic.php?pid=23322#p23322" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Hase]]></name>
				<uri>https://forum.php-myadmin.ru/profile.php?id=4004</uri>
			</author>
			<updated>2013-06-27T15:48:59Z</updated>
			<id>https://forum.php-myadmin.ru/viewtopic.php?pid=23322#p23322</id>
		</entry>
</feed>
