Jump to content

Recommended Posts

I've been working a lot lately with the dynamic output of my javascript based on my PHP classes.

 

Viewing the source is pretty messy, but the ease and adaptability of my javascript code is beautiful.

 

To the point: I just found that there is a method in ASP called RegisterClientScriptBlock that allows client side code to be registered with the browser. I am guessing that the code would not be visible by viewing the page source; and I would think that the page would load faster since the browser is being 'force fed' instead of having to read the code in the source, determining where HTML stops and jscript begins, extra decisions that can add up, yadda yadda.

 

I did a search in this form for "RegisterClientScriptBlock" and found no results; guessing that if it's being talked about, that string would be used. I also searched the web for "RegisterClientScriptBlock Equivalent for PHP" ... nada.

 

So what's up?

 

Thanks

 

The Jungle Guru

⼿⽊⽣

 

I've been working a lot lately with the dynamic output of my javascript based on my PHP classes.

 

Viewing the source is pretty messy, but the ease and adaptability of my javascript code is beautiful.

 

To the point: I just found that there is a method in ASP called RegisterClientScriptBlock that allows client side code to be registered with the browser. I am guessing that the code would not be visible by viewing the page source; and I would think that the page would load faster since the browser is being 'force fed' instead of having to read the code in the source, determining where HTML stops and jscript begins, extra decisions that can add up, yadda yadda.

 

I did a search in this form for "RegisterClientScriptBlock" and found no results; guessing that if it's being talked about, that string would be used. I also searched the web for "RegisterClientScriptBlock Equivalent for PHP" ... nada.

 

So what's up?

 

Thanks

 

The Jungle Guru

⼿⽊⽣

 

From what little I know of .NET (currently enrolled in an ASP.NET 3.5/C# class), I'm somewhat familiar with what you're asking.  No, there's no built-in function to register your JavaScript with PHP, at least, none that I know of.  You can simply put it all in an external library file, or within a static header file that's included with each page.  Or, if you need to write the JavaScript dynamically, you'll have to roll up your sleeves and write it directly using echo, print, or a HEREDOC.  There's no real clean way to doing it that way, I'm afraid.

 

Hey, mind telling me in a private message why registering client-side scripts with the server would be a good thing?  My book describes how to do it by using one of the three Register methods, but not why I'd want to.  It doesn't even mention what registering a script does!

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.