Search code examples
javascriptjquerypythoncherrypymako

Can a javascript file be dynamic (different for each client when he loads) ? How?


Each client on the site has his own composition of HTML elements. Some may have 3 elements while others may have 123. There is little if any similarity between the elements. And each element requires specific code to manipulate the various elements. In fact each client may need a different JavaScript file after each search or action taken on the site.

So, how can the server supply customized Javascript files on the fly for each session?

I use python/cherrypy/mako on the server side...

TIA

Dennis


Solution

  • Use multiple JavaScript files and just include the ones you need..

    If you really do need every JavaScript file to be dynamically generated, take a look at inline JavaScript:

    <html>
    <head>
        <script>
            some_client_specific_code();
        </script>
    </head>
    ...