Forum Discussion
Mike Jansen
Jun 12, 2017Iron Contributor
Sharepoint framework > reference to custom javascript
I try to convert an "old" content editor webpart to a SharePoint Modern webpart. My original script contains a few references to custom .js files. In my new solution I added this to my "webpart.ts" f...
Jun 13, 2017
Hi Mike Jansen,
You could put those scripts anywhere ( as long as they are accesible).
Have you looked at the Azure CDN?
Jun 13, 2017
Is there a reason why your not just migrating your scripts to TypeScript?
Something like this is easy to implement and closer to where you should want to be:
export default class MyFunctionsTurnedIntoAClass {
public oldfunction1() {
....
}
public oldfunction2() {
....
}
....
}
- Mike JansenJun 13, 2017Iron Contributor
Yes ;-)
This is my first test and I am not familiar with Typescript. What I try to do is get my test working and then step-by-step convert it to typescript.
- Mike JansenJun 26, 2017Iron Contributor
Took some time but I figured it out. This is what I did:
1. No reference in the "Config.json"
2 Changed my custom script:
var CustomScript = function testFunction() { alert("test"); }; module.exports = { CustomScript: CustomScript };3. in my .ts file did in the render method
const MyCustomScript: any = require('./myscript'); MyCustomScript.CustomScript()Now my "alert" shows up.