Jump to content

why .js files in end of body in 1.6


PauloKruz

Recommended Posts

Hi,

 

I´m testing beta version 1.6.0.3 and all .js files are in the end of body.

 

For this motive i have 2 questions?

 

a ) Why are all .js files located in the end of body

b ) Where in core files this function are? Because i need change it.

 

I need call JQuery in header because i have some modules with errors because have functions calling JQuery before JQuery .js are loaded

 

Error in Firebug:

ReferenceError: jQuery is not defined.

 

 

Link to comment
Share on other sites

Hi,

 

There are in the footer for performance reasons.

 

Please use addJquery() and addJS() in your module http://doc.prestashop.com/pages/viewpage.action?pageId=11272250

 

Please consider adding a external script for your module using addJS() and not inline scripts. Your inline scripts should be defered at the end too if you did it in the template though, and after javascript queue. Can you please try a git version https://github.com/PrestaShop/PrestaShop/archive/1.6.zip ? maybe we can find why your scripts are not being deffered properly after jquery loading.

 

Best regards

  • Like 1
Link to comment
Share on other sites

Hi,

 

There are in the footer for performance reasons.

 

Please use addJquery() and addJS() in your module http://doc.prestashop.com/pages/viewpage.action?pageId=11272250

 

Please consider adding a external script for your module using addJS() and not inline scripts. Your inline scripts should be defered at the end too if you did it in the template though, and after javascript queue. Can you please try a git version https://github.com/PrestaShop/PrestaShop/archive/1.6.zip ? maybe we can find why your scripts are not being deffered properly after jquery loading.

 

Best regards

 

very interesting topic, we are just getting to release new module for controlling which java loaded top bottom for 1.4|1.5.

 

with 1.6 how do we specify java that needs to be loaded top via for example a module? 

 

Thanks in advance for your time.

  • Like 1
Link to comment
Share on other sites

Hi,

 

I am sorry but for the moment this specification is not forecasted for 1.6. A module needs to use core functions, or if you do no want to use these functions, your inline scripts will be defered after the javascript stack and after Jquery loading. If you Include an other version of Jquery, this will be passed through a noconflict script too.

 

Best regadrs

  • Like 1
Link to comment
Share on other sites

Hi,

 

I am sorry but for the moment this specification is not forecasted for 1.6. A module needs to use core functions, or if you do no want to use these functions, your inline scripts will be defered after the javascript stack and after Jquery loading. If you Include an other version of Jquery, this will be passed through a noconflict script too.

 

Best regadrs

 

Thank you Gregory,

 

I think what we are providing for 1.4-1.5 will be relevant in 1.6 as we now support async/defer options by java file.

 

Thanks for keeping my hobby interesting...Keep up the good work.

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Sorry, I can not formulate my question ...

 

My script javascript must absolutely be placed in the head tag to make it work.

Out since 1.6, these scripts are placed in the body tag.

 

Can t be forced placement JavaScript script tag in the head?

 

Thank you for your help.

 

Hi, yes simply edit the header.tpl in your theme folder and place there.  You can either make a call like

<script type="text/javascript" src="/pointer to .js file"></script>

or, and this might be better if you tell ps in performance to Compress inline JavaScript in HTML and do something like this:

		<script type="text/javascript">
			your java script
		</script>

note the problem with placing in header.tpl file is that it will always be called even if that page does not require the .js to render.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

As of 1.6 ALL inline JavaScript is being pushed to the bottom of the page. Even those scripts being manually written in to a template file.  This has been a major headache for me since upgrading.

Как исправили?

How to Fix?

Link to comment
Share on other sites

  • 7 months later...
×
×
  • Create New...