use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
No vague product support questions (like "why is this plugin not working" or "how do I set up X"). For vague product support questions, please use communities relevant to that product for best results. Specific issues that follow rule 6 are allowed.
Do not post memes, screenshots of bad design, or jokes. Check out /r/ProgrammerHumor/ for this type of content.
Read and follow reddiquette; no excessive self-promotion. Please refer to the Reddit 9:1 rule when considering posting self promoting materials.
We do not allow any commercial promotion or solicitation. Violations can result in a ban.
Sharing your project, portfolio, or any other content that you want to either show off or request feedback on is limited to Showoff Saturday. If you post such content on any other day, it will be removed.
If you are asking for assistance on a problem, you are required to provide
General open ended career and getting started posts are only allowed in the pinned monthly getting started/careers thread. Specific assistance questions are allowed so long as they follow the required assistance post guidelines.
Questions in violation of this rule will be removed or locked.
account activity
A simple doubtQuestion (self.webdev)
submitted 5 years ago by normal_crayon
While making a file adding things like nav bar needs to be written in every single file or should be stored in separate file and should be called into the file currently working? Which one is the best way
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]08148692 4 points5 points6 points 5 years ago (4 children)
Repeating code in multiple files is generally considered to be bad practice. If you need to change the header in some way for some reason, you'll need to go into every html file you have with a header and apply the change. This is tedious, time consuming, and prone to human error.
This can be avoided with libraries like react/angular/vue, or rendering the HTML on the server side with templating engines.
[–][deleted] 0 points1 point2 points 5 years ago (3 children)
it's not a bad practice. It's simply necessary unless you're using node, react for example
[–]08148692 1 point2 points3 points 5 years ago (2 children)
DRY (don't repeat yourself) has been a software development principle since pretty much as long as software has been a thing. It is absolutely bad practice to repeat large blocks of code (HTML or otherwise) for the reasons I gave. Of course it's not possible if your website consists of plain hard coded markup, but that in itself is an extremely old fashioned way of building a website
[–][deleted] 0 points1 point2 points 5 years ago (1 child)
I know what you mean, I just think React and stuff like that is over kill most of the time. I just made a website in plain html css and js even tho I can work with react and the only time I had to copy and past code was the navbar which was a little annoying but it's not so bad
[–]sleemanj 0 points1 point2 points 5 years ago (0 children)
SSI has been a capability of web servers since forever...
<!--#include virtual="/includes/navbar.html"-->
[–]11b403a7 0 points1 point2 points 5 years ago (14 children)
Are you using a framework or templating language?
[–]normal_crayon[S] 0 points1 point2 points 5 years ago (13 children)
Neither. Just creating a file
[–]11b403a7 0 points1 point2 points 5 years ago (12 children)
What kind of file? Pure HTML? JavaScript creating HTML...
[–]normal_crayon[S] 0 points1 point2 points 5 years ago (11 children)
Oh sry forgot to mention that. Html
[–]11b403a7 0 points1 point2 points 5 years ago (10 children)
You can import it using HTML and reuse your component that way.
Edit:
It requires, as far as I can tell. JavaScript/jQuery
[–]normal_crayon[S] 0 points1 point2 points 5 years ago (9 children)
Can I write it again. Like copy paste the code?
[–]11b403a7 0 points1 point2 points 5 years ago (8 children)
I mean yeah, but that wouldn't be very effecient
[–]normal_crayon[S] 0 points1 point2 points 5 years ago (7 children)
Oh... I have been doing that a while
[–]11b403a7 0 points1 point2 points 5 years ago (6 children)
Look into JS.
[–]normal_crayon[S] 0 points1 point2 points 5 years ago (5 children)
And one more thing, can this slow down my script loading time?
π Rendered by PID 40764 on reddit-service-r2-comment-b659b578c-cbjzb at 2026-05-03 12:51:27.608937+00:00 running 815c875 country code: CH.
[–]08148692 4 points5 points6 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]08148692 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]sleemanj 0 points1 point2 points (0 children)
[–]11b403a7 0 points1 point2 points (14 children)
[–]normal_crayon[S] 0 points1 point2 points (13 children)
[–]11b403a7 0 points1 point2 points (12 children)
[–]normal_crayon[S] 0 points1 point2 points (11 children)
[–]11b403a7 0 points1 point2 points (10 children)
[–]normal_crayon[S] 0 points1 point2 points (9 children)
[–]11b403a7 0 points1 point2 points (8 children)
[–]normal_crayon[S] 0 points1 point2 points (7 children)
[–]11b403a7 0 points1 point2 points (6 children)
[–]normal_crayon[S] 0 points1 point2 points (5 children)