Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove roboto font from elements for faster page load #8

Open
AndreasGalster opened this issue Jul 18, 2015 · 18 comments
Open

Remove roboto font from elements for faster page load #8

AndreasGalster opened this issue Jul 18, 2015 · 18 comments

Comments

@AndreasGalster
Copy link

I am currently working on a website and page speed is not sufficient. I'm currently looking at all the resources being loaded and trying to optimize. I've noticed I'm loading the roboto font which take a huge load of the loading time and I'm not even using roboto since I'm using my own fonts.

Is there an option to remove roboto from being loaded with paper elements without having to manually remove the roboto font in the individual paper-element font imports? This adds almost 4 seconds of loading time to my site and that's not even in production online.

@JosefJezek
Copy link

@addyosmani
Copy link

As @JosefJezek kindly pointed out, the font-roboto-local import is probably your best bet here.

@notwaldorf
Copy link
Contributor

We're looking at removing font-roboto from typography.html in the 2.0 version of elements, and requiring you to explicitly import it.

@AndreasGalster
Copy link
Author

It would be a good idea to do something similar with colors.html. The amount of colors is just too many imported by default. People that don't use the color theme (our site for example) at all will have to import those colors for nothing. Currently we're importing colors.html but don't use any of those colors in our own elements, instead we defined our own colors based on the color pattern.

Maybe do something similar to how iron-icons does it, import one or two basic color schemes (e. g. google-blue and greyscale-shades) and the rest of it can be imported with colors-advanced-scheme.html or something like that.

@lorenzleutgeb
Copy link

I am having the same issue. My app does not use Roboto, but gold-email-input depends on paper-styles which in turn depends onfont-roboto thus adding completely unnecessary load time to my page.

Furthermore I'd argue that it is unacceptable for any user of this package to not be able to suppress cross-origin calls! E.g. what if I do not want my application to talk to Google's servers?

@Bamieh
Copy link

Bamieh commented Aug 21, 2016

+1 needs to be removed, for now i exclude it during vulcanization.

@JosefJezek
Copy link

@lorenzleutgeb
Copy link

@JosefJezek That's a workaround, not a resolution of the original issue.

@AndreasGalster
Copy link
Author

Also that workaround really kills time whenever you have to do a new build (guess you could automate it I guess but would be nicer to just have it removed).

@notwaldorf I recall some talks about version 2.0 of all the elements in the future. Do you have a roadmap and outline what you want to achieve for the 2.0 milestone? Not just for this one but in general. It would be interesting to see where you are going (not just at the Polymer summit please, I really hate the pre-summit 3 months no updates at all wait time) and how we can help out potentially in the future.

@notwaldorf
Copy link
Contributor

/cc @tjsavage

@Bamieh
Copy link

Bamieh commented Aug 24, 2016

@JosefJezek a much easier "workaround" would be to exclude it during vulcanization:

grunt.config.set('vulcanize', {
...
   stripExcludes : [
        'assets/bower_components/font-roboto/roboto.html',
        'assets/bower_components/iron-icons/iron-icons.html'
   ]
...

@AimForNaN
Copy link

AimForNaN commented Apr 12, 2017

I'd be happy if the async attribute were added to the link[rel="stylesheet"] element that loads the font.

@iSuslov
Copy link

iSuslov commented Jul 29, 2017

Best solution for now:

  1. Create .bowerrc file in the same folder where you have bower.json.
  2. Add the following inside the file:
{
...
  "scripts": {
    "postinstall": "node -e \"require('fs').writeFileSync('bower_components/font-roboto/roboto.html', '')\""
  }
...
}

this will clean the contents of roboto.html after bower install
3) reinstall bower components

Another option:

  1. Create .bowerrc file in the same folder where you have bower.json.
  2. Add the following inside the file:
  "ignoredDependencies": [
    "font-roboto"
  ]

so .bowerrc will look something like this:

{

...

{
  "ignoredDependencies": [
    "font-roboto"
  ]
}

...

}
  1. reinstall bower components, you will see in the console:

bower paper-styles#1 - 2 skipped font-roboto

Now you can run polymer serve.

To build without errors run this command before build:

mkdir bower_components/font-roboto/ && touch bower_components/font-roboto/roboto.html

@iSuslov
Copy link

iSuslov commented Jul 30, 2017

@TrueFusion for your specific case postinstall script in .bowerrc will look like this:

{
...
  "scripts": {
    "postinstall": "node -e \"var fs=require('fs'); var f=fs.readFileSync('bower_components/font-roboto/roboto.html', 'utf8'); fs.writeFileSync('bower_components/font-roboto/roboto.html', f.replace(/link /, 'link async '))\""
  }
...
}

@jaichandra
Copy link

@notwaldorf is font-roboto remove from polymer 2.0 elements? or is this still pending.

@notwaldorf
Copy link
Contributor

@jaichandra The 2.0 elements didn't have any true breaking changes (that weren't required by the hybrid port), so font-roboto is still there, as removing it would have been a breaking change

@hzmsrv
Copy link

hzmsrv commented Feb 1, 2019

so in the new year 2019 it still breaking the app and all element to jam in loading?
my app got 100%cpu because of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants