Where/How does Kentico bundle its JS files?

Kentico Dev asked on August 5, 2020 00:07

Upon testing a website using Google's page speed insights I noticed that one issue was a fairly large javascript file that was included with each response.

Using Chrome dev tools, I can see that the script is here: /kentico/bundles/forms/scripts?v=-NrRP...

I can view the code of that script and it seems to be this file: ~\Kentico\Content\FormComponents\FileUploader\file-uploader.js

The code returned has this at the top:

/* Minification failed. Returning unminified contents.
(3463,421938-421939): run-time error JS1010: Expected identifier: .
(3463,421938-421939): run-time error JS1195: Expected expression: .

I cannot figure out:

  • Where this gets added to the script bundle by Kentico.
  • Why it is not compressed
  • Why does is it included with every response even if no form is on the page.

Any help would be appreciated.

Correct Answer

Dmitry Bastron answered on August 5, 2020 10:47

Hi, Kentico Dev!

Yes, you are right, unfortunately this is a known issue and Kentico always references all scripts required for MVC form builder, even if there is no form on the page. This method in your view is including this bundle @Html.Kentico().PageBuilderScripts(). There are a couple of workarounds that can reduce the impact though, but will not solve the problem completely.

  1. Delete large JS files if you don't use these form controls
    • If you don't use File Uploader form control - delete \Kentico\Content\FormComponents\FileUploader\file-uploader.js file
    • If you don't use US Phone control - delete \Kentico\Content\FormComponents\USPhone\inputmask.js (it's quite big as well)
    • Once you've done this, there should be only \Kentico\Scripts\forms\updatableFormHelper.js that is left in the bundle, but this script is necessary for form builder for to submit.
  2. Explicitly reference only small script required for form submit (File Uploader and US Phone form controls won't work then)
    • In preview mode add @Html.Kentico().PageBuilderScripts()
    • On frontend (non-preview) render \Kentico\Scripts\forms\updatableFormHelper.js

Hope it helps.

1 votesVote for this answer Unmark Correct answer

Recent Answers

Brenden Kehren answered on August 5, 2020 01:02

Reinstall the Kentico Nuget packages and try again. Most likely an issue with something that happened with the install of the package.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.