React VS Code external scripts - javascript

I'm using VS Code with React and I wanted to try this: codepen.io/andystent/pen/GRgjBdJ?editors=0010
In the settings at codepen appear 5 links to 5 external scripts which this pen is using so it can work. I downloaded the JS from this pen, saved it in a file and imported it in /src folder, but I do not know how and where to add those 5 external scripts so my script could work. Can you please help me? How can I add external scripts to my react project? And where to add them (index.html/App.js/index.js etc)?

Related

Add a second JS file in Express / EJS app

here the link to a project I am working on to learn express / ejs / API.
https://github.com/aspnet82/books
I would like to add a second JS file to manage clicks etc.. possibly using jQuery (also vanilla JS is ok... at the moment there is no jQuery installed).
// books.ejs
<script src="public/js/index.js" charset="utf-8"></script>
</body>
But when I add the tag and indicate the index.js as source into the books.ejs file the content of the webpages is not showing anymore, is like either the app.js or the index.js are loaded at time.
If index.js is empty the ejs file is loaded properly.
What is the best way to manage events on a node / express app? For example, if I click on a element. Is this a Js file into the public folder as it is static content? and how do I call this in the app.js file?
Thanks for any help

Adding a javascript file to Angular7 dist folder

I'm building an app in Angular7 and it's ready to go but I need to create a plain javascript (hopefully could be minified) to be included in the websites which are going to use the main Angular app. This script will embed the app into an iframe when users click buttons or links. What I want is to have that script and the Angular app as part of the same bundle but not included as part of the angular app. Just available to control what the host website can do to embed our main app. If there is another approach to solve this problem I will appreciate it
Create custom js file
exports.myFunction = function myFunction() {
alert('External custom js');
}
Add this JavaScript file in scripts array in angular.json file.
"scripts": [
.....
"src/assets/js/custom.js"
]
If in your js file have function myFunction you can declare in the component
import {myFunction} from '../assets/js/custom.js';
I make a demo for custom.js
https://stackblitz.com/edit/angular-custom-js?file=src/app/app.component.ts

Liferay portlet + Single page html, css, javascript

I have a static Single Page - html, css and javascript files. I have tested by deploying it into apache-tomcat and it works.
I would like to convert this html, css and javascript as Porlet.
So far, I have done the followings,
Created the liferay - maven project (Through eclipse) [I have build and tested, this porlet is working when i deploy as war in LifeRay)
In liferays maven project: ..src/main/webapp/ folder i have created a new folder called myapp
Have pasted all the html, css, javascripts inside the myapp folder
In the view.jsp file, i have included the myapp/index.html file.
Build the war and deployed into liferay.
Here, it is successfully picking the myapp/index.html in liferay porlet. However, it is not picking any resources inside the index.html (css, javascript).
Here, how can i make this porlet up and working correctly. Please assist. Kindly note that, i have tested this static page in independent tomcat server, it works fine. So that means, all the resource path that I have given is correct in index.html

Import 3rd party lib file to visual studio

I am using Visual Studios and trying to use http://davidshimjs.github.io/qrcodejs/
But I can't seem to import the library...
I just added the file to the project and tried to use it in the Book.js(View).
But it doesn't seem to work..
Am I missing any steps?
Add the qrcodejs file to a bundle in your App_Start/BundleConfig.cs and then render the bundle in the view where you need it or the default bundle in your layout file.
Also make sure the js file is in your Scripts folder.

Avoid multiple src files in my html page

I have a website I'm working on in Visual Studio 2013 and I'm mainly using AngularJS 1.2.6. In my index.html I have a src line for each .js file which for 3 page is 6 lines, 1 js file for each controller and 1 js page for each view.
Is there a way I could consolidate all of these lines into 1 .js file and call that .js file in my index.html?
Yes, you can use something like grunt.js to build a custom build script for your .js files. In your case, you may want to use grunt-contrib-concat with grunt-contrib-watch.
If you are not familiar with grunt, feel free to read the tutorial.

Categories

Resources