#1 WordPress forum plugin created by gVectors Team

wpForo – WordPress Forum Plugin
  • Home
  • Forum
  • Migrate to wpForo
  • Addons
  • Addons Demo
  • Documentation

Forum

Home | Forum

wpDiscuz - WordPress Comment Plugin
  • Forums
  • Members
  • Recent Posts
Forums
Main Support Forums
How-to and Troubles...
Remove CSS and JS o...
 
Share:
Share
Tweet
Share
Notifications
Clear all

[Closed] Remove CSS and JS on non wpForo page

    Last Post
RSS

BigBatT
Posts: 12
BigBatT - Facebook
 BigBatT
Topic starter
March 8, 2020 4:45 pm
(@bigbatt)
Active Member
Joined: 2 years ago

Hi guys,

I am a new user happy to use wpForo. Great job, great plugin.

I have to ask one thing: Is it possible to remove all CSS and Js files from pages that are not forums?

Thanks in advance and best regards

Excusatio non petita, accusatio manifesta
Mala tempora currunt sed peiora parantur

Topic Tags
CSS js
10 Replies
Sofy
Posts: 4057
Sofy - Facebook Sofy - Twitter
 Sofy
Admin
March 9, 2020 7:26 am
(@sofy)
Support Team
Joined: 4 years ago

Thank you @bigbatt!

The wpForo scripts and CSS are being loaded only on the wpForo pages.

Probably you see the wpForo JS and CSS because you've added the wpForo widgets on that pages? 

In case you want to say thank you !)
We'd really appreciate and be thankful if you leave a good review on plugin page. This is the best way to say thank you to this project and support team.

2 Replies
BigBatT
 BigBatT
(@bigbatt)
Joined: 2 years ago

Active Member
Posts: 12
BigBatT - Facebook
March 9, 2020 8:34 am
Reply toSofySofy

@sofy

I don't use widgets wpForo in any pages
If you want see my site here

The forum page is full width but without any widgets

Other plugins I use:

Akismet Anti-Spam 4.1.3

TinyMCE Advanced 5.3.0

Ultimate Member 2.1.4

Ultimate Member - Maybe load assets 1.0.2

wpDiscuz 5.3.5

 

 Immagine.jpg

Excusatio non petita, accusatio manifesta
Mala tempora currunt sed peiora parantur

Sofy
 Sofy
Admin
(@sofy)
Joined: 4 years ago

Support Team
Posts: 4057
Sofy - Facebook Sofy - Twitter
March 9, 2020 8:47 am
Reply toBigBatTBigBatT
Sofy

ok @bigbatt, thank you!

let me ask the developers about this. I'll back to you asap. 

 

In case you want to say thank you !)
We'd really appreciate and be thankful if you leave a good review on plugin page. This is the best way to say thank you to this project and support team.

BigBatT liked
Sofy
Posts: 4057
Sofy - Facebook Sofy - Twitter
 Sofy
Admin
March 9, 2020 1:18 pm
(@sofy)
Support Team
Joined: 4 years ago

@bigbatt,

The CSS and JS files belong to the wpForo widgets. I'm really sorry, but currently, there is no way to not load the files if the widgets are not included on that page. However, the developers are going to optimize this in future updates. 

In case you want to say thank you !)
We'd really appreciate and be thankful if you leave a good review on plugin page. This is the best way to say thank you to this project and support team.

BigBatT liked
1 Reply
BigBatT
 BigBatT
(@bigbatt)
Joined: 2 years ago

Active Member
Posts: 12
BigBatT - Facebook
March 9, 2020 2:08 pm
Reply toSofySofy

@sofy,

Below is the code used by Ultimate Member.
Maybe it can serve as an example.

Best regards


<?php

/*
Plugin Name: Ultimate Member - Maybe load assets
Description: Remove CSS and JS on non UM pages
Version: 1.0.2
Author: Ultimate Member
Author URI: http://ultimatemember.com/
*/

add_action( 'wp_print_footer_scripts', 'um_remove_scripts_and_styles', 9 );
add_action( 'wp_print_scripts', 'um_remove_scripts_and_styles', 9 );
add_action( 'wp_print_styles', 'um_remove_scripts_and_styles', 9 );
add_action( 'dynamic_sidebar', 'um_remove_scripts_and_styles_widget' );

/**
* Maybe remove Ultimate Member CSS and JS
* @global WP_Post $post
* @global bool $um_load_assets
* @global WP_Scripts $wp_scripts
* @global WP_Styles $wp_styles
* @return NULL
*/
function um_remove_scripts_and_styles() {
global $post, $um_load_assets, $wp_scripts, $wp_styles;

// Set here IDs of the pages, that use Ultimate Member scripts and styles
$um_posts = array(0);

// Set here URLs of the pages, that use Ultimate Member scripts and styles
$um_urls = array(
'/account/',
'/activity/',
'/groups/',
'/login/',
'/logout/',
'/members/',
'/my-groups/',
'/password-reset/',
'/register/',
'/user/',
);

if ( is_admin() || is_ultimatemember() ) {
return;
}

$REQUEST_URI = $_SERVER['REQUEST_URI'];
if ( in_array( $REQUEST_URI, $um_urls ) ) {
return;
}
foreach ( $um_urls as $key => $um_url ) {
if ( strpos( $REQUEST_URI, $um_url ) !== FALSE ) {
return;
}
}

if ( !empty( $um_load_assets ) ) {
return;
}

if ( isset( $post ) && is_a( $post, 'WP_Post' ) ) {
if ( in_array( $post->ID, $um_posts ) ) {
return;
}
if ( strpos( $post->post_content, '[ultimatemember_' ) !== FALSE ) {
return;
}
if ( strpos( $post->post_content, '[ultimatemember form_id' ) !== FALSE ) {
return;
}
}

if ( empty( $wp_scripts->queue ) || empty( $wp_styles->queue ) ) {
return;
}

foreach ( $wp_scripts->queue as $key => $script ) {
if ( strpos( $script, 'um_' ) === 0 || strpos( $script, 'um-' ) === 0 || strpos( $wp_scripts->registered[$script]->src, '/ultimate-member/assets/' ) !== FALSE ) {
unset( $wp_scripts->queue[$key] );
}
}

foreach ( $wp_styles->queue as $key => $style ) {
if ( strpos( $style, 'um_' ) === 0 || strpos( $style, 'um-' ) === 0 || strpos( $wp_styles->registered[$style]->src, '/ultimate-member/assets/' ) !== FALSE ) {
unset( $wp_styles->queue[$key] );
}
}
}

/**
* Check whether Ultimate Member widget was used
* @param array $widget
*/
function um_remove_scripts_and_styles_widget( $widget ) {
if ( strpos( $widget['id'], 'um_' ) === 0 || strpos( $widget['id'], 'um-' ) === 0 ) {
$GLOBALS['um_load_assets'] = TRUE;
}
}

 

Excusatio non petita, accusatio manifesta
Mala tempora currunt sed peiora parantur

Anonymous20
Posts: 1602
 Anonymous20
March 9, 2020 2:13 pm
(@anonymous20)
Noble Member
Joined: 6 years ago

I don't see any .js from wpForo in your page, only 2 css.

Still, what is the exact problem you are having with that?

1 Reply
BigBatT
 BigBatT
(@bigbatt)
Joined: 2 years ago

Active Member
Posts: 12
BigBatT - Facebook
March 9, 2020 6:08 pm
Reply toAnonymous20Anonymous20

@anonymous20

You sure didn't get a good look at her.
wpForo loads 3 CSS and 1 JS in every part of the site.
This causes slowdowns and conflicts with other CSS/JS.

If you don't understand what I'm asking, read the previous post where I indicate how Ultimate Member solved this issue by creating an ad-hoc plugin that loads UM files only in the dedicated pages and not in the whole website

 

Regards

 

 Immagine.jpg

Excusatio non petita, accusatio manifesta
Mala tempora currunt sed peiora parantur

Anonymous20
Posts: 1602
 Anonymous20
March 9, 2020 6:41 pm
(@anonymous20)
Noble Member
Joined: 6 years ago

@bigbatt

No conflicts from wpForo unless you optimize things. I have a tone load of plugins/js/css in my pages, i even optimize them, merge them, deffere them, i haven't seen any conflict.

Also i see no slowdowns or anthything bad from your site:

https://www.webpagetest.org/result/200309_FF_b760189de055f2e4d42e42dc07e9d350/

And there is a widget.js, you are correct, still i fail to see any problems.

 

2 Replies
BigBatT
 BigBatT
(@bigbatt)
Joined: 2 years ago

Active Member
Posts: 12
BigBatT - Facebook
March 9, 2020 7:14 pm
Reply toAnonymous20Anonymous20

@anonymous20

I hope you don't want to make a problem from a simple request, beacouse I don't care.

I just asked the wpForo Team if it was possible to load files CSS and JS only in the forum page; if possible same to the Ultimate Member.

https://developers.google.com/speed/pagespeed/insights/?hl=IT&url=https%3A%2F%2Fwww.bigbatt.it%2F&tab=desktop

That's all.

 

Excusatio non petita, accusatio manifesta
Mala tempora currunt sed peiora parantur

Sofy
 Sofy
Admin
(@sofy)
Joined: 4 years ago

Support Team
Posts: 4057
Sofy - Facebook Sofy - Twitter
March 9, 2020 7:23 pm
Reply toBigBatTBigBatT
Anonymous20

@bigbatt,

I've already answered your question here: https://wpforo.com/community/how-to-and-troubleshooting-2/remove-css-and-js-on-non-wpforo-page/#post-37748

Thank you for the code you've provided us. I'll inform the developers for sure. Currently, I close this topic. 

 

In case you want to say thank you !)
We'd really appreciate and be thankful if you leave a good review on plugin page. This is the best way to say thank you to this project and support team.

BigBatT liked
  All forum topics
  Previous Topic
Next Topic  
Related Topics
  • CSS Color Issue
    1 month ago
  • Hiding or collapsing alt forums
    1 month ago
  • Alternating Table Colors Not Possible in Simplified Topic View?
    2 months ago
  • want to change a number of styling features without changing other associated colours
    2 months ago
  • Line and paragraph spacing
    2 months ago
Topic Tags:  CSS (49), js (1),

Forum Search

Join Us!

Download wpForo plugin
on WordPress.org

wpForo Addons

wpforo-private-messages wpforo-advanced-attachments-128x128 wpforo-embeds-128x128 wpForo User Custom Fields addon wpForo – Blog Cross Posting addon wpForo Ads Manager wpForo – WooCommerce Memberships Integration wpForo Emoticons wpForo – Tenor GIFs Integration
View all Addons »

Recent Topics

  • Prevent access to the url "community"

    By totor, 18 hours ago

  • Dark mode

    By Vijiki, 22 hours ago

  • Menu location

    By Vijiki, 1 day ago

  • Setting recent topics on forum frontend

    By Vijiki, 2 days ago

  • Draft draft users post on wpforo

    By Vijiki, 2 days ago

  • How to remove content from email notification

    By Vijiki, 2 days ago

Topic Tags

  • translation49
  • css49
  • plugin conflict48
  • seo45
  • new features44
  • buddypress42
  • ultimate member40
  • avatar40
  • forum40
  • moderation38
  • login38
  • registration36
  • threaded layout35
  • cache33
  • editor32
  • menu32
  • shortcode31
  • spam29
  • forum accesses29
  • phrases28
View all tags (2163)

Recent Posts

  • RE: New wpForo

    @robert So, will this update feature such as changi...

    By gsmdahisi, 8 hours ago

  • RE: Dark mode

    @chris I did switch to dark mode and I have 3 Questions...

    By Vijiki, 10 hours ago

  • Prevent access to the url "community"

    Hello everyone. We use wpforo on a site with a public...

    By totor, 18 hours ago

  • RE: How to make logo appear on the BP photo

    Just like here, the wpDiscuz Image shown above the menu...

    By Chris, 20 hours ago

  • RE: Draft draft users post on wpforo

    @vijiki, You can set the post/topic unapproved, so th...

    By Chris, 22 hours ago

  • RE: Menu location

    Thanks

    By Vijiki, 23 hours ago

  • Answer to: Problem with private forum

    Hi @darkkang, In the Forum Accesses, disable "Can vie...

    By Chris, 23 hours ago

Share:
Share
Tweet
Share
  Forum Statistics
20 Forums
9,765 Topics
49.5 K Posts
4 Online
44.1 K Members

Latest Post: New wpForo Our newest member: shortterm Recent Posts Unread Posts Tags

Forum Icons: Forum contains no unread posts Forum contains unread posts

Topic Icons: Not Replied Replied Active Hot Sticky Unapproved Solved Private Closed

Powered by wpForo | Copyright © 2016-2022 gVectors Team
Copyright Registration Service - Click here for more information or to register work
wpForo is Registered with the IP Rights Office
Copyright Registration Service

Ref: 4477265538
  • Home
  • Forum
  • Migrate to wpForo
  • Addons
  • Addons Demo
  • Documentation