Pierrox15 Posted August 29, 2019 Share Posted August 29, 2019 Hello, I'm writing theme and some Tb core js file are not needed. I know how to override js from module, But How can I disable some js from the core properly in my thème? I have made a conditionnal preg_match in the header.tpl for test, but when I set the concat js option in Backoffice this is ignored {foreach from=$js_files item=js_uri} {if !preg_match("/(ui.position|jquery.autocomplete|jquery.scrollTo|jquery.serialScroll|bxslider|ui.position|blocksearch)/", $js_uri)} <script type="text/javascript" src="{$js_uri|escape:'html':'UTF-8'}"></script> {/if} {/foreach} Link to comment Share on other sites More sharing options...
0 datakick Posted August 29, 2019 Share Posted August 29, 2019 13 minutes ago, Pierrox15 said: Hello, I'm writing theme and some Tb core js file are not needed. I know how to override js from module, But How can I disable some js from the core properly in my thème? I have made a conditionnal preg_match in the header.tpl for test, but when I set the concat js option in Backoffice this is ignored {foreach from=$js_files item=js_uri} {if !preg_match("/(ui.position|jquery.autocomplete|jquery.scrollTo|jquery.serialScroll|bxslider|ui.position|blocksearch)/", $js_uri)} <script type="text/javascript" src="{$js_uri|escape:'html':'UTF-8'}"></script> {/if} {/foreach} That's not theme's responsibility. You don't know why these js files are requested to be included in the page -- there might be some third party module that need some of these libraries and it *asked* core to include it. Theme's responsibility is to include everything that was requested. Otherwise you break stuff. I know it's stupid, and it leads to bloated themes with trillions of unused js libs, but that that how it is. Link to comment Share on other sites More sharing options...
0 Pierrox15 Posted August 29, 2019 Author Share Posted August 29, 2019 Ok, thx. Another question about "Smart" cache for CSS the compressed css filename is different on home / category / product. Is it a bug? does it desserve a bug report? Normally at the first load, all my CSS will be ready for all the website ; I think. Link to comment Share on other sites More sharing options...
0 datakick Posted August 29, 2019 Share Posted August 29, 2019 I don't think that's a bug. Every page has its own set of css/js dependencies -- there are modules that includes some css / javascript on homepage only, or on product page only. Core collects all these assets and creates a bundle from it. These bundles are different, since they consist of different content. Of course, this could (and should) be optimized. For example, core could calculate intersection of these bundles, and generate some common.js / common.css files. Every page would then serve this common.js + page-specific.js files. There would be more resources on the page, but overall performance would probably increase - common assets would be cached by browsers. You can file this as an enhancement request Link to comment Share on other sites More sharing options...
0 Pierrox15 Posted August 30, 2019 Author Share Posted August 30, 2019 (edited) 19 hours ago, datakick said: Of course, this could (and should) be optimized. For example, core could calculate intersection of these bundles, and generate some common.js / common.css files. Every page would then serve this common.js + page-specific.js files. There would be more resources on the page, but overall performance would probably increase - common assets would be cached by browsers. You can file this as an enhancement request I think it will be more simple for optimize, calculate intersection is a good idea but in practice it feel a bit complicated for something simple. for example my compressed CSS have only 1ko variation between product / category / home. The files have at 99% the same code. So I have reported here: https://github.com/thirtybees/thirtybees/issues/1032 thx Edited August 30, 2019 by Pierrox15 Forget report Link to comment Share on other sites More sharing options...
0 datakick Posted August 30, 2019 Share Posted August 30, 2019 6 minutes ago, Pierrox15 said: I think it will be more simple for optimize, calculate intersection is a good idea but in practice it feel a bit complicated for something simple. for example my compressed CSS have only 1ko variation between product / category / home. The files have at 99% the same code. It's not that simple. This extra 1k code can have huge impact. There can be some initialization script that expects to run on specific page only. If we executed this script on different page, it might produce a lot of errors. These errors or exception can prevent other js scripts to initialize correctly, and... we have not working page. There's no shortcut here. The page must contain all the javascript that's requested. Nothing less, nothing more. So, the only way to optimize this is indeed to split it into common + specific javascript chunks. Link to comment Share on other sites More sharing options...
0 Pierrox15 Posted August 30, 2019 Author Share Posted August 30, 2019 7 minutes ago, datakick said: and... we have not working page. Ok I see. For me a classic PHP HTML app will be totally accessible & usable without JS. JS is the icing on the cake and come at the end to improve UX. So that how it is. Link to comment Share on other sites More sharing options...
Question
Pierrox15
Hello,
I'm writing theme and some Tb core js file are not needed.
I know how to override js from module, But How can I disable some js from the core properly in my thème?
I have made a conditionnal preg_match in the header.tpl for test, but when I set the concat js option in Backoffice this is ignored
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now