[MWPW-140627] [MEP] Replace MEP placeholders when loading fragments #3193
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we insert text/HTML in MEP, we call the replacePlaceholders function to replace any already known placeholders (aka MEP placeholders). We want to do the same thing when it's fragment content that has a MEP placeholder. So we'll want to call that function again from fragments.js
At the end of fragments.js init function, we are calling handleMepCommands. Afterwards, I think we should test for config.placeholders and fragment's html having a placeholder. If so, run it through replacePlaceholders.
Note, since there were now 3 if statements that all repeated importing personalization.js for 3 different functions, they were moved to all be nested inside 1 if.
QA instructions
The main element on the test page only uses MEP placeholders, but the gnav also uses regular placeholders. To test this PR, check the performance tab in dev tools for the before and after links. Not only should the LCP be much faster, but it should not call placeholders.json until after LCP in the after link.
Resolves: MWPW-140627
Test URLs: