Injecting JavaScript and CSS into individual pages

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
10/19/2010 3:42:38 AM
Gravatar
Total Posts 44

Injecting JavaScript and CSS into individual pages

Hi,
I'm currently configuring my first site to use mojoPortal, the site has(will have) many pages with individual style elements and small amounts of javascript/jquery.  I know that I can create a separate skin folder and add the CSS to that, but that seems a bit of overkill.  I do intend to create content templates, but what I would like to do is to inject CSS/JS references and script into the head element of individual pages. So for example I create a new page, add the HTMl content and then select CSS references and JS references from a drop-down list.  I would also have the option from the Edit Page screen to paste script directly into the head of the individual page. 

The architecture I am looking for is the ability to have one master file of global CSS and JS and then each individual page carries it's own unique and minimal package.

I'm quite happy to do this, but can someone please point me in the right direction.

Thanks.

10/19/2010 6:55:07 AM
Gravatar
Total Posts 18439

Re: Injecting JavaScript and CSS into individual pages

I recommend put all your css together in the same skin, it will be minified and cached by the browser so no need for separate http requests or extra ones on some pages. It will be cached on the first page and the browser never needs to request the file again. There is no benefit to having a bunch of  little css files used on different pages.

For javascript you can add page specific javascript in the html editor (CKeditor) using source view.

This forum is really for people developing custom features in Visual Studio, there are ways to add javascript from server side code in custom development, but that does not sound like what you are doing.

10/19/2010 7:53:29 AM
Gravatar
Total Posts 44

Re: Injecting JavaScript and CSS into individual pages

Thanks Joe,

The site I am building will have many users (hopefully), some will have no knowledge of CSS or JS and probably not much HTML, what I was hoping to do was create a series of templates with place holders for text and images and which would automatically inject all the specific CSS and JS for that page and the user would just use the HTML editor to fill in the blanks.  I appreciate what you say about the CSS, I'll have another look at the content templates.

P.S. Thanks for a great product, I tried Umbraco (2 days - too much reliance on XSLT) and then N2 (5 days - utterly confusing documentation), before finding what I really wanted in mojoPortal. 

You must sign in to post in the forums. This thread is closed to new posts.