Filter by title

ASP.NET Core MVC / Razor Pages UI: JavaScript Resource Loader API

abp.ResourceLoader is a service that can load a JavaScript or CSS file on demand. It guarantees to load the file only once even if you request multiple times.

Loading Script Files

abp.ResourceLoader.loadScript(...) function loads a JavaScript file from the server and executes it.

Example: Load a JavaScript file

abp.ResourceLoader.loadScript('/Pages/my-script.js');

Parameters

loadScript function can get three parameters;

  • url (required, string): The URL of the script file to be loaded.
  • loadCallback (optional, function): A callback function that is called once the script is loaded & executed. In this callback you can safely use the code in the script file. This callback is called even if the file was loaded before.
  • failCallback (optional, function): A callback function that is called if loading the script fails.

Example: Provide the loadCallback argument

abp.ResourceLoader.loadScript('/Pages/my-script.js', function() {
  console.log('successfully loaded :)');
});

Loading Style Files

abp.ResourceLoader.loadStyle(...) function adds a link element to the head of the document for the given URL, so the CSS file is automatically loaded by the browser.

Example: Load a CSS file

abp.ResourceLoader.loadStyle('/Pages/my-styles.css');

Contributors


Last updated: October 14, 2025 Edit this page on GitHub

Was this page helpful?

Please make a selection.

To help us improve, please share your reason for the negative feedback in the field below.

Please enter a note.

Thank you for your valuable feedback!

Please note that although we cannot respond to feedback, our team will use your comments to improve the experience.

ABP Community Talks
AI-Powered .NET Apps with ABP & Microsoft Agent Framework
18 Dec, 17:00
Online
Register Now
ABP Live Webinar
Webinar Calendar Webinar Calendar
Discover
ABP Platform
Register Now
Dec 17
Wednesday,
17:00 UTC
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.