-2

I need to change the design of various pages of a website developed in Ruby on Rails. I was thinking of modifying the HAML files to include CSS and Javascript to make the desining nicer and more responsive.

What could be the drawbacks of such an approach? I have came across such example here.

1
  • This question is either too broad, opinion based or requires discussion and so is off-topic for Stack Overflow. If you have a specific, answerable, programming issue, please provide full details. Commented Jan 21, 2016 at 9:55

1 Answer 1

2

The drawbacks are exactly the same well known drawbacks of including anything but content in HTML.

  • Your muddling content with presentation and behavior. This leads down quick path to a total mess of inline everything and generally poor development practices.
  • Your CSS and JS will not leverage caching properly between pages that might otherwise share components.
  • Your CSS and JS will not be properly minified.
  • You will not be able to use code quality tools properly on CSS or JS.
  • The execution order of your JS is going to be confusing.
  • Your code indentation and quality in general will suck. This especially applies to HAML.
  • Other developers will hate you.

Rails even generates per controller stylesheets and scripts by default to make separating views from assets easier.

But in general the idiom of "per page" styles and behavior should be avoided unless you are creating trivial brocureware, you get better code quality and reuse if you try to envision a set of reusable parts or modules - HTML class attibutes are cheap - parsing a huge document with a junk drawer of CSS/JS is expensive.

Sign up to request clarification or add additional context in comments.

1 Comment

Take a look at Foundation or Bootstrap if you want some basic clues about how to create reusable parts for responsive apps.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.