web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How can I include .js ...
Power Apps
Unanswered

How can I include .js and other files in my PCF component?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

I'm trying to create a code component that will be a wrapper around a 3rd. party JavaScript based HTML component.  I need to include the JavaScript file, plus all files it needs, into my PCF solution to be deployed as one package.  I'm trying to load the .js file as follows in my index.ts file:

 

 let scriptNode = document.createElement("script");
 scriptNode.setAttribute("type", "text/javascript");
 scriptNode.setAttribute("src", "folder/component.js");
 scriptNode.onload = () => { ... };
 document.head.appendChild(scriptNode);

 

This approach works fine if the component is in a CDN somewhere that I can point to using a full URL, but I need it to work "locally".  Maybe I need to mess with the ControlManifest.input.xml file?
 
Hope this is clear.  Thanks for any help.
I have the same question (0)
  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @Anonymous , 

     

    The script tags that you dynamically inject, would be executed at runtime. I understand that you would like to bundle the script in cour PCF.

    Maybe this older post will help you: https://powerusers.microsoft.com/t5/Power-Apps-Pro-Dev-ISV/Issue-Using-external-javascript-files/m-p/316412

     

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for your reply.  I added the following to my index.ts:

        import "./folder/component.js";
    But still no luck;  it can't load the file.  How can I ensure all the files needed by component.js are included in the component?
  • cchannon Profile Picture
    4,702 Moderator on at

    Have you added the additional resources to your manifest?

    Resources Element - Power Apps | Microsoft Docs

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 762

#2
11manish Profile Picture

11manish 640

#3
Valantis Profile Picture

Valantis 548

Last 30 days Overall leaderboard