Skip to content
Snippets Groups Projects
Commit 98bea268 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'dev#133420_vu_avec_google_insight_deferrer_quelques_js' into 'master'

dev #133420 Rendering performances : defer loading of JQuery UI and leaflet

See merge request !3976
parents 344fd714 56ea6519
Branches
Tags
1 merge request!3976dev #133420 Rendering performances : defer loading of JQuery UI and leaflet
Pipeline #13106 passed with stage
in 46 minutes and 38 seconds
- ticket #133420 : Performances de rendu : chargement JQuery UI et Leaflet différés
\ No newline at end of file
......@@ -161,10 +161,10 @@ class Class_ScriptLoader {
*/
public function loadLeafletJS() {
return $this
->addAdminScript('leaflet-1.6.0/leaflet.js')
->addAdminScript('leaflet-1.6.0/leaflet.js', true)
->addJQueryReady('L.Icon.Default.imagePath="' . URL_ADMIN_JS . 'leaflet-1.6.0/images/"')
->addOPACPluginScript('leaflet-ajax-gh-pages/dist/leaflet.ajax.min.js')
->addOPACPluginScript('leaflet.fullscreen-master/Leaflet.fullscreen.min.js')
->addOPACPluginScript('leaflet-ajax-gh-pages/dist/leaflet.ajax.min.js', true)
->addOPACPluginScript('leaflet.fullscreen-master/Leaflet.fullscreen.min.js', true)
->addOPACPluginStyleSheet('leaflet.fullscreen-master/leaflet.fullscreen.css')
->addStyleSheet(URL_ADMIN_JS . 'leaflet-1.6.0/leaflet.css');
}
......@@ -211,7 +211,7 @@ class Class_ScriptLoader {
return $this;
return $this
->addScript(JQUERYUI)
->addScript(JQUERYUI, true)
->addStyleSheet(JQUERYUI_CSS);
}
......@@ -283,8 +283,8 @@ class Class_ScriptLoader {
/**
* @return ScriptLoader
*/
public function addOPACPluginScript($script) {
return $this->addScript(BASE_URL."/public/opac/java/".$script);
public function addOPACPluginScript($script, $defer = false) {
return $this->addScript(BASE_URL."/public/opac/java/".$script, $defer);
}
......
......@@ -131,6 +131,7 @@ class ScriptLoaderJsAndCssTest extends PHPUnit_Framework_TestCase {
->addScript('opac/cycle.min')
->addScript('opac/slides.min.js')
->addJQueryReady('alert()')
->loadJQueryUI()
->html();
}
......@@ -191,6 +192,13 @@ class ScriptLoaderJsAndCssTest extends PHPUnit_Framework_TestCase {
}
/** @test */
public function jqueryUIShouldBeDeferred() {
$this->assertContains(JQUERYUI.'?v='.Class_ScriptLoader::getInstance()->getCacheHash().'" defer >',
$this->html);
}
/** @test */
function inAjaxModeReadyScriptsShouldBeInSetTimeoutFunction() {
$this->html = Class_ScriptLoader::getInstance()->beAjax()->html();
......@@ -277,4 +285,4 @@ class ScriptLoaderNotificationsBarTest extends ModelTestCase {
}
}
?>
\ No newline at end of file
?>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment