The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Styles and scripts directly in templates?

3 posters

Go down

Solved Styles and scripts directly in templates?

Post by Kami-sama December 20th 2017, 8:01 pm

Simple question, is it okey to have style and script directly in template itself?

I was thinking, that if I put a script inside the template instead of having it applied to ALL PAGES this would boost page loading. Same with styles. I wonder if there are any drawbacks of doing so? I guess general style and script settings should be used when changes are wanted for elements in every forum page....


Last edited by Kami-sama on December 20th 2017, 9:17 pm; edited 1 time in total
Kami-sama
Kami-sama
Forumember

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Solved Re: Styles and scripts directly in templates?

Post by Ape December 20th 2017, 8:29 pm

Hello there is no real problem with it as long as you don't over do it.

If you add a lot it may slow things down a lot but little codes are fine.

Only real problem is if we have updates them codes may not work and it will not show up on our tools if we need to help you fix the problems, or some updates may not work due to your changes.


Styles and scripts directly in templates? Left1212Styles and scripts directly in templates? Center11Styles and scripts directly in templates? Right112
Styles and scripts directly in templates? Ape_b110
Styles and scripts directly in templates? Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19110
Reputation : 1991
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Solved Re: Styles and scripts directly in templates?

Post by Kami-sama December 20th 2017, 8:34 pm

But if a template layout is adjusted anyways it should not be a problem?
In your opinion, what is better, considering that template layout is adjusted either way. Is it better to have adjusted layout style and script together or separately?
Kami-sama
Kami-sama
Forumember

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Solved Re: Styles and scripts directly in templates?

Post by Ape December 20th 2017, 8:36 pm

it's always better to code them together so its faster loading and it makes it easier to changed codes when needed.


Styles and scripts directly in templates? Left1212Styles and scripts directly in templates? Center11Styles and scripts directly in templates? Right112
Styles and scripts directly in templates? Ape_b110
Styles and scripts directly in templates? Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19110
Reputation : 1991
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Solved Re: Styles and scripts directly in templates?

Post by Kami-sama December 20th 2017, 8:41 pm

I do agree. Was only wondering if there would be anything bad doing so. Cool.

While adding style is straightforward. The script I noticed is slightly different.
Why is this needed in the template:
Code:
<script type="text/javascript">
//<![CDATA[
Kami-sama
Kami-sama
Forumember

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Solved Re: Styles and scripts directly in templates?

Post by Guest December 20th 2017, 8:50 pm

The CDATA thing has to do with XML, I don't know exactly what it means but a google search would probaly help you. It's safe to remove it. Adding JS and CSS in the templates is not necessarily a bad thing. If you have a lot of codes, it's a good idea to add them that way:css that has to do with topics to the topic templates and so on. But if you have few lines of code, you should just add them in a single file.
avatar
Guest
Guest


Back to top Go down

Solved Re: Styles and scripts directly in templates?

Post by Kami-sama December 20th 2017, 9:11 pm

Justice™ wrote:The CDATA thing has to do with XML, I don't know exactly what it means but a google search would probaly help you. It's safe to remove it. Adding JS and CSS in the templates is not necessarily a bad thing. If you have a lot of codes, it's a good idea to add them that way:css that has to do with topics to the topic templates and so on. But if you have few lines of code, you should just add them in a single file.

Yeah, I have lots ;D especially style.
That's why I decided to sort it next to templates they are applied to.

CDATA sections in XML. In an XML document or external parsed entity, a CDATA section is a section of element content that is marked for the parser to interpret purely as textual data, not as markup.
Kami-sama
Kami-sama
Forumember

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Solved Re: Styles and scripts directly in templates?

Post by Ape December 20th 2017, 9:34 pm

is this now solved for you as its marked solved by Icon ?


Styles and scripts directly in templates? Left1212Styles and scripts directly in templates? Center11Styles and scripts directly in templates? Right112
Styles and scripts directly in templates? Ape_b110
Styles and scripts directly in templates? Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19110
Reputation : 1991
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Solved Re: Styles and scripts directly in templates?

Post by Draxion December 27th 2017, 7:36 am

Problem solved & topic archived.
Please read our forum rules: ESF General Rules
Draxion
Draxion
Helper
Helper

Male Posts : 2518
Reputation : 321
Language : English
Location : USA

https://www.talesoftellene.com/

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum