/    Sign up×
Community /Pin to ProfileBookmark

should you use jQuery .load Header & Footer Links.

So I’ve seen this snippet on stackoverflow, I am just wondering if this is a good way of adding header & footer links from a separate file, and is it well supported on all browsers?

snippet:

“`
<script>
$(function(){
$(“#header”).load(“header.html”);
$(“#footer”).load(“footer.html”);
});
</script>
“`

if this is not a good way to do this, what is?

to post a comment
HTMLJavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@NachfolgerMay 19.2020 — @joshlw#1618583

No, this is horrific. You're making two additional requests each time someone loads the page. Use a backend language to insert the header/footer dynamically.
Copy linkTweet thisAlerts:
@VITSUSAMay 20.2020 — I agree with Nachfolger, you should use a backend language to insert the header/footer dynamically.
×

Success!

Help @joshlw spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 3.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,

tipper: Anonymous,
tipped: article
amount: 10 SATS,
)...