Title: Poor functioning of beautiful code function in JS code.
Last modified: October 15, 2022

---

# Poor functioning of beautiful code function in JS code.

 *  Resolved [michalrama](https://wordpress.org/support/users/michalrama/)
 * (@michalrama)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/poor-functioning-of-beautiful-code-function-in-js-code/)
 * Hello
 * This is not a support request, I just gave an illustrative example of how badly
   the “beautiful code” function works for JS code, which is particularly important
   to me.
 * I would be happy to improve it.
 * Thank you
 *     ```
       jQuery(function(){
           var navIsBig = true;
           var $nav = jQuery('#masthead .custom-logo');
       	var height_original = jQuery('#masthead .custom-logo').css("height").replace("px","");
       	var height_small = height_original * 0.666;
       	var width_original = jQuery('#masthead .custom-logo').css("width").replace("px","");	
       	var width_small = width_original * 0.666;
   
       jQuery(document).scroll( function() {
          var value = jQuery(this).scrollTop();
   
         if ( value > 100 && navIsBig ){
             $nav.stop().animate({
                  height:height_small,width:width_small
             },100);
             navIsBig = false;
         } else if (value <= 100 && !navIsBig ) {
             $nav.stop().animate({
                 height:height_original,width:width_original
             },100);
             navIsBig = true;
         }
       });
       });
       ```
   
 *     ```
       jQuery(function(){
       		var navIsBig = true;
       		var $nav = jQuery('#masthead .custom-logo');
       		var height_original = jQuery('#masthead .custom-logo').css("height").replace("px","");
       		var height_small = height_original * 0.666;
       		var width_original = jQuery('#masthead .custom-logo').css("width").replace("px","");
       		var width_small = width_original * 0.666;
       		jQuery(document).scroll( function() {
       			var value = jQuery(this).scrollTop();
       			if ( value > 100 && navIsBig ){
       				$nav.stop().animate({
       					height:height_small,width:width_small
       				}
       									,100);
       				navIsBig = false;
       			}
       			else if (value <= 100 && !navIsBig ) {
       				$nav.stop().animate({
       					height:height_original,width:width_original
       				}
       									,100);
       				navIsBig = true;
       			}
       		}
       							   );
       	}
       		  );
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Author [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * (@diana_burduja)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/poor-functioning-of-beautiful-code-function-in-js-code/#post-16103498)
 * Hello,
 * the Simple Custom CSS & JS plugin uses this [code formatting library](https://codemirror.net/2/demo/formatting.html)(
   more specifically the “[autoFormatRange](http://view-source:https://codemirror.net/2/lib/util/formatting.js)”
   CodeMirror extension) , which was left underdeveloped by the CodeMirror authors.
 * If you want to improve it, feel free to write the code and share it with us.

Viewing 1 replies (of 1 total)

The topic ‘Poor functioning of beautiful code function in JS code.’ is closed to
new replies.

 * ![](https://ps.w.org/custom-css-js/assets/icon-128x128.png?rev=1303730)
 * [Simple Custom CSS and JS](https://wordpress.org/plugins/custom-css-js/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-css-js/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-css-js/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-css-js/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-css-js/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-css-js/reviews/)

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [js](https://wordpress.org/support/topic-tag/js/)

 * 1 reply
 * 2 participants
 * Last reply from: [SilkyPress](https://wordpress.org/support/users/diana_burduja/)
 * Last activity: [3 years, 7 months ago](https://wordpress.org/support/topic/poor-functioning-of-beautiful-code-function-in-js-code/#post-16103498)
 * Status: resolved