Jump to content

[solved] 1.6.0.7 No JS files loaded?


Pete78
 Share

Recommended Posts

Just did a 1.6.0.7 from 1.6.0.6 one click upgrade.

 

Is it possible that no JS files are loaded?

 

At least, I don't see any in the page sources... 

 

Anybody else examined this problem?

Share this post


Link to post
Share on other sites

Custom theme, yes. FO: No js at all, just some snippets from paypal module etc.

BO: JS loaded normal.

 

Just debugging and I think in the Controller.class, method smartyOutputContent might be a problem.

 

JS Files were added to the js_path (at least I can output them all) but the call to the javascript.tpl file seems to cause some problems. I will investigate further...

Share this post


Link to post
Share on other sites

Actually I don't want to switch again, dont want to lose module activation and deactivation pos etc. configuration.

 

Now I just replaced in the controller.php the

 

"protected function smartyOutputContent($content)"

 

method with an older one ( 1.6.0.6.

 

and js gets loaded as expected..

 

-> there might be a problem...with the latest one.

Share this post


Link to post
Share on other sites

OK, got it:

There should be a variable called 

 

PS_JS_DEFER in the configuration table.

 

you can replace it with this...for a quick fix at line 417 in Controller.php

 

$defer = true; //(bool)Configuration::get('PS_JS_DEFER');

 

 

I guess, (without further investigation) this variable will be set in the install process...

Edited by Pete78 (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

Sorry for confusing, now I found the real problem:

 

The PS_JS_DEFER comes from the "move javascript to the end configuration

 

if this is turned to  "YES". everything works as expected but if switched to "NO" no JS will be loaded at all.

 

actually the source code is just wrong here...

  • Like 2

Share this post


Link to post
Share on other sites

Important Note:

 

before putting this code in you have option to move JavaScript to the bottom, for 1.6.0.7 and higher.

 

back office-->advanced parms-->Move JavaScript to End-->YES!

 

this is the PREFERRED way to load JavaScript, it makes your above the fold load much faster.

 

can you check your themes/yourtheme/header.tpl

 

you should see this code, which will load .js if load to bottom turned off

{if isset($js_defer) && !$js_defer && isset($js_files) && isset($js_def)}
	{$js_def}
	{foreach from=$js_files item=js_uri}
	<script type="text/javascript" src="{$js_uri|escape:'html':'UTF-8'}"></script>
	{/foreach}
{/if}

  • Like 5

Share this post


Link to post
Share on other sites

Thanks for the hint El Patron, 

this one was missing in the theme file. I guess it was introduced in one of the last releases ( the leo theme I am using is pretty new though).

 

Thanks again and I marked the problem as "resolved".

 

Peter

Edited by Pete78 (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Hello, Leo the administrator told me I have to follow this instructions, but I'm really new using prestashop, I've looked for this code, but is not in the header.tpl file, Do I have to paste it in the file?, If yes, where should I paste it?

Thank you!

 

 

can you check your themes/yourtheme/header.tpl

 

you should see this code, which will load .js if load to bottom turned off

{if isset($js_defer) && !$js_defer && isset($js_files) && isset($js_def)}
	{$js_def}
	{foreach from=$js_files item=js_uri}
	<script type="text/javascript" src="{$js_uri|escape:'html':'UTF-8'}"></script>
	{/foreach}
{/if}

 

 

Thanks for the hint El Patron, 

this one was missing in the theme file. I guess it was introduced in one of the last releases ( the leo theme I am using is pretty new though).

 

Thanks again and I marked the problem as "resolved".

 

Peter

Share this post


Link to post
Share on other sites

Paste it just after this code:

{if isset($css_files)}
    {foreach from=$css_files key=css_uri item=media}
        <link rel="stylesheet" href="{$css_uri|escape:'html':'UTF-8'}" type="text/css" media="{$media|escape:'html':'UTF-8'}" />
    {/foreach}
{/if}

Share this post


Link to post
Share on other sites

Important Note:

 

before putting this code in you have option to move JavaScript to the bottom, for 1.6.0.7 and higher.

 

back office-->advanced parms-->Move JavaScript to End-->YES!

 

this is the PREFERRED way to load JavaScript, it makes your above the fold load much faster.

  • Like 4

Share this post


Link to post
Share on other sites

Thanks for this brilliant tip,

 

I was afraid I would have to investigate for the week !!

 

I have been asking for days now to the theme developer AND the Prestashop Addons team WHY my expensive theme refused to work correctly after I updated from 1.6.0.5 to 1.6.0.8 ... I wish they just sent me the url of this topic earlier ! How come something like this can happen in the code ? Sometimes, the Prestashop guys seriously scare me .

 

Thanks again !

Share this post


Link to post
Share on other sites

Thanks for this brilliant tip,

 

I was afraid I would have to investigate for the week !!

 

I have been asking for days now to the theme developer AND the Prestashop Addons team WHY my expensive theme refused to work correctly after I updated from 1.6.0.5 to 1.6.0.8 ... I wish they just sent me the url of this topic earlier ! How come something like this can happen in the code ? Sometimes, the Prestashop guys seriously scare me .

 

Thanks again !

 

Personally the PS development team did an excellent job but the problem is getting all the developers on board to use 'best practice'.  We want to decrease 'above the fold' page render by moving JavaScript to the bottom.  If your theme does not support bottom loaded JavaScript then you can use my module JavaPro, here is link to module forum. 

 

 I did some looking at other eCommerce cms's, and specifically the featured shops with 'big names', they not only do not support JavaScript bottom but don't have CCC of .css and .js.  So in my honest opinion the ps developers continue to push the envelope in providing best in class features, we just have to wait for theme developers to catch up. (like herding cats) :)

  • Like 2

Share this post


Link to post
Share on other sites

  • 3 months later...
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More