I have a problem...
I have an Aurelia pplication where I would like to load styles from Index.html instead of app.html.
Why?
Because when the application starts, there is a slight timespan before styles are loaded where user can see unstyled application.
As I am loading all the styles in app.html, the main.js executes before, and it loads all the plugins that takes some time.
Is there a way to do this?
You just use a standard link element to link to the css file in index.html. This stylesheet will not be bundled with your application bundle, and it can't be as you need access to it before your bundle file(s) is/are parsed.
<link rel="stylesheet" type="text/css" href="mystyles.css" media="screen" />
You can add a gulp task to copy this file at build time, as the Aurelia CLI is built on gulp tasks.
Related
I am trying to use a single HTML stylesheet that I've created between multiple apps script web app projects. I have the HTML stylesheet hosted on an external site but cannot figure out the code to include that external stylesheet into my apps script projects.
I've currently got it working with the following code in my Index.html file:
<link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css">
<?!= include('stylesheet') ?>
The include function calls:
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}
And my stylesheet is a separate HTML file in my Apps Script.
This all works well, but I'd like to have a central repository elsewhere (I've read that I cannot link to an Apps Script file in another project) for my stylesheet so that whatever changes I make will update to all of my Apps Script projects automatically.
To do this, I've uploaded my stylesheet.html to a website and have taken the link that points to the file (i.e. http://www.test.com/stylesheet.html) and tried to do the following without success:
<link rel="stylesheet" href="http://www.test.com/stylesheet.html">
I've placed this in the head element of my Index.html file, and I also tried it above the head element. Neither worked.
I've also tried to just use the include function that worked as mentioned above and modify my stylesheet.html to be blank except for:
<link rel="stylesheet" href="http://www.test.com/stylesheet.html">
None of this seems to work, wondering if anyone else has any thoughts on how this might be possible.
Host CSS file in Google Drive
Create a .css stylesheet file and host it on Google Drive.
Change the uploaded file permissions to publish it on the Web.
Now copy the published file ID and use it to build the following URL:
https://drive.google.com/uc?export=view&id=FILE-ID-GOES-HERE
Now include the generated URL to your HTML page using the <link/> tag in this way:
<link rel="stylesheet" href="google_drive_link_goes_here">
Reference
Host CSS or JS file on Google Drive
I have created a basic application using Create React App. I came across different methods to load link tags to HTML while surfing on the internet.
Currently, WebPack is creating link tags as:
<link href="styles.css" rel="stylesheet">
But I want link tags to be rendered in a different form such as:
<link rel="preload" href="styles.css" as="style">
<noscript><link rel="stylesheet" href="styles.css"></noscript>
Is there any way I can achieve it?
If you built the project using create-react-app, then you won't find a customizable webpack.config.js (there's one, but it's handled by react-scripts).
According to Dan, they don't allow customization of plugins to minimize potential issues.
So, if you want to add a plugin to a react app that was bootstrapped with create-react-app. You'll have to run npm run eject and this will make all the configurations files available for manual customization.
Once you ejected the project, you can preload resources for Webpack using the preload-webpack-plugin. Details here
Basic example webpack.config.js:
plugins: [
new HtmlWebpackPlugin({
title: 'My Cool App',
template: './app/index.html'
}),
new PreloadWebpackPlugin()
]
That should preload the assets and dependencies automatically for you. Additional usage details here
I am not sure what is happening with that behavior but when :
i include the following script link in the HTML
<link href='./css/style.css' rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="./js/app.js"></script>
the page is not applying css or js if I just open the HTML page in any browser directly, but it runs on the server and apply the links
when i include the following instead of the pervious link
<link href='../static/css/style.css' rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../static/js/app.js"></script>
it Runs when open the Page in browser directly , but it is not applying when run on server
i can not figure out why this happening
The reason behind this is because when you run on the server, Spring boot maps the src/main/resources/static folder to your context root (usually /).
That means that if you have the following structure:
src/
main/
resources/
static/
myStyle.css
templates/
index.html
Both the src/main/resources/static/myStyle.css and the src/main/resources/templates/index.html will be available as /myStyle.css and /index.html.
If you're using Spring boot you should never include the static/ (or templates/) part in your links/references. You should never open the HTML page directly in your browser since this does not reflect any real environment.
To make it work locally you should run the Spring boot application and open the application through your browser, not just some HTML file in the project itself.
i'm working on a bootstrap template locally on my dev server.. the template loads some resources via CDN..
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<!--font-awesome-->
<link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<!-- Ionicons -->
<link href="//code.ionicframework.com/ionicons/1.5.2/css/ionicons.min.css" rel="stylesheet" type="text/css" />
Problem is this slows me down because everytime I hit refresh to check the changes on my page (localhost) the darn thing has to load the resources online again and again..
So i tried to open the resources via the link and save em locally. but this breaks because i guess there are more things to it than just the CSS code.
Is there an easy way to "localize" these things?
Thanks guys
This are the steps I followed to use CDN CSS resource locally:
Download and extract the font pack from here
Copy the ionicons.css to your project
Copy the fonts folder to your project
Ensure the font urls within ionicons.css properly reference the fonts path within your project.
Include a reference to the ionicons.css file from every webpage you need to use it.
In my case I include this in main.html
<link href="css/ionicons.css" rel="stylesheet" type="text/css" />
then simply add the icon and icon's classname to an HTML element.
<i class="icon ion-home"></i>
and folders are in this way:
- project_name
* css --> ionicons.css
* fonts --> ionicons.eot, ionicons.svg, ionicons.ttf, ionicons.woff
To preface this answer, I'm not sure that this solution is considered 'easy' but it will get you the ability to host locally vs. being dependent on the CDNs. The easy solution is using the CDNs. That being said:
The bootstrap.min.css file is easy to localize, you can go to getbootstrap.com and get it out of the Download Bootstrap option.
Localizing Font Awesome is a bit more work. Here you need to copy the entire font-awesome directory into your project. You can download it from this URL: http://fortawesome.github.io/Font-Awesome/ . You'll end up with a directory folder named something like font-awesome-4.2.0, which will contain a series of sub-folders: css, fonts, less and scss. You'll also need to call the local font-awesome.min.css file in the head section of your HTML. See the following GitHub link for more information on setting up Font Awesome locally: http://fortawesome.github.io/Font-Awesome/get-started/
Ionicons is similar to Font Awesome setup. From the following Ionicons web page, you'll need to Download the directory and include it in your project: http://ionicons.com/ . You'll need to call the local ionicons.min.css file in the head section of your HTML after you have the directory setup.
old question, but I think there's an easy solution now:
you can install the node package by using npm install ionicons
https://www.npmjs.com/package/ionicons
Save the css/js files locally from url and change path.
eg:- css/ionicons.min.css
http://code.ionicframework.com/ionicons/1.5.2/css/ionicons.min.css
http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.1.0/css/font-awesome.min.css
http://code.ionicframework.com/ionicons/1.5.2/css/ionicons.min.css
I have a rails app I put my index.html in public folder and it shows when i go to port 3000 but it doesn't show it with css, I have my css folder and i tried putting it into assets stylesheets but nothing is happing? where do i put my folder with all the css files in it? would i need to change the way my index.html referances my css files?
for now my index.html in public folder references the css files like this <link href="css/styles.css" rel="stylesheet">
i've looked into some tutorials but their a bit complex in understanding
Things put in the public folder won't be processed by the asset pipeline. This isn't the "rails way" at all, but you can just move your .css to your public folder and call it like you're calling it now.
To gain access to the asset pipeline the quickest way I can think of is to just scaffold generate something, fill in the view with your HTML and then you can call via asset pipeline. However by default the root route isn't set so you'll have to navigate to localhost:3000/whatever-controller-you-generated-here
I highly recommend reading this guide before you go much further http://guides.rubyonrails.org/
First of all if you are using rails then why are you using static page like this. If you really want to use this then you have to specify stylesheet like this
<link href="/assets/application.css" rel="stylesheet" />