Path

ez projects / ezjscore / forum / general / possible to force ezscript_...


Possible to force ezscript_require to put a js at the top ?

You need to be logged in to post messages in the forums. New users may register here.

Jerome Despatis

Member since:
11 November 2008

Posts: 20

Wednesday 26 January 2011 4:13:11 pm

Hi,

I'm using dojo as js framework.

In a template (included in pagelayout.tpl), i perform an ezscript_require('dojo.js').
However as I've all around js script that uses dojo, dojo HAS to be included in the top of the global minified .js file...

Hence my question: as I can see in setPersistentArray, it's possible to push a js at the top of js_files
=> Is it possible to do it with ezscript_require ?

For now, a workaround for me would be to code a custom template operator ezscript_require_prepend that force $append = false in the call to setPersistentArray

But is there another easier way to achieve this ?
Up

Gaetano Giunta

Member since:
09 January 2008

Posts: 241

Wednesday 26 January 2011 4:24:51 pm

can you try to add that script as parameter to the ezscript_load call instead?

Principal Consultant International Business
Member of the Community Project Board

Up

Jerome Despatis

Member since:
11 November 2008

Posts: 20

Wednesday 26 January 2011 4:55:53 pm

Then it works on the frontoffice, but I get a bunch of errors on the backoffice

Indeed, due to ezscript_load in my template, one big js block loading jquery is not included in the global .js in the backoffice...

Up

André R.

Member since:
14 January 2008

Posts: 170

Wednesday 26 January 2011 10:29:23 pm

I think he meant modifying the ezjscore_load call to include dojo.js as first param, calling it several times will indeed cause issues.

The cleaneste is to add it to FrontendJavaScriptList/BackendJavaScriptList (first is for frontend and second is for backend) in design.ini to make it load as one of the first scripts on all pages.

Lead Engineer eZ Publish
@: http://twitter.com/andrerom

Up

Jerome Despatis

Member since:
11 November 2008

Posts: 20

Thursday 27 January 2011 5:03:28 pm

Yes it works !

Thanks André

My google page speed is happy

I'd like now to kill those http queries towards yahoo to retrieve yui stuff 2in3.1 :)
Up

You need to be logged in to post messages in the forums. New users may register here.