Jump to content

Recommended Posts

I'm developing a site that uses a lot of ajax. I'm using php and the zend framework for the backend.

I'm finding myself putting in a lot of javascript files in the layout file since I can't add them selectively because the

head section of the page doesn't reload. Is there a way to address this issue?

 

Thanks,

 

Brian

Link to comment
https://forums.phpfreaks.com/topic/226261-building-a-ajax-website/
Share on other sites

I want to add javascript files only when they are necessary. Not include them statically in the head section of my layout file. In the zend framework js files can be added dynamically in the view file but since ajax is being used this is not possible.

Where possible you should try and pack (and I mean pack, using jsmin or similar) all your js into 1 file anyway. It makes for less http requests.

 

and to compact it even more (and solve your problem), you can dynamically build that .js file with server-side scripting. You'd have your .js files in a dir and  have your script tag point to a single blah.js and mod_rewrite that to point to blah.php and and in blah.php you would file_get_contents the necessary ones and compact it and output the single custom file. 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.