0

I have a lot of JavaScript and jQuery functions that are all working fine, but it's quite fragmented and hard to maintain as some are in Elementor HTML widgets, others in specific Pho functions annd some in an enqueued JS file.

Ideally I'd like to move everything into the single JS file so it's easier to maintain, but would there be any performance implications? For example some scripts only need to run on specific pages but I assume they would load everywhere in a file. Would this have any realistic performance implications or am I being overly obsessive...?

2
  • Unfortunately there are a lot of unknown variables here which make this question impossible to answer with knowledge of WordPress core alone - thus it may be considered off-topic for our site. That said, there could be performance implications in either direction - JavaScript in an HTML widget on multiple pages could be loaded for each page and only cached along with the page, which may or may not be slower than caching a single JS file independently across all pages. But unless you have a truly substantial amount of JS it's unlikely to matter either way, in practice.
    – bosco
    CommentedMay 5, 2022 at 19:14
  • That makes sense, I hadn't factored in the caching side of thingsCommentedMay 6, 2022 at 3:42

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.